home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / array.doc < prev    next >
Text File  |  1995-03-31  |  2KB  |  91 lines

  1. (Comp.sys.handhelds) 
  2. Item: 2362 by ppetto at NCoast.ORG 
  3. Author: [Peter Petto] 
  4.   Subj: HP48 Vectors to Array? 
  5.   Date: Fri Mar 08 1991 
  6.  
  7. An HP-48SX question ... I would like to combine two vectors 
  8. into an array as follows 
  9.  
  10.      [ 2 4 6 8 ]  plus  [ 2 9 27 81 ] 
  11.  
  12.                  to get 
  13.  
  14.              [[ 2 4 6 8 ] 
  15.               [ 3 9 27 81 ]] 
  16.  
  17. I have been able to do this manually (via the MatrixWriter 
  18. application) but not under progam control.  Can anyone offer 
  19. any advice?  (Thanks.) 
  20.  
  21. --- 
  22. Peter Petto        |     ppetto@ncoast.org 
  23. Bay Village, Ohio  |  73125.617@compuserve.com 
  24.  
  25. ---------- 
  26.  
  27.   Resp: 2 of 3 by bson at fruit-and-fibre.ai.mit.edu 
  28. Author: [Jan Brittenson] 
  29.   Date: Sat Mar 09 1991 11:24  
  30.  
  31. How about: 
  32.  
  33. << SWAP ARRY-> LIST-> DROP  
  34.     DUP 2 + ROLL ARRY-> LIST-> DROP 
  35.     DUP 2 + ROLL + 2 SWAP OVER / OVER 
  36.     ->LIST ->ARRY 
  37. >> 
  38.  
  39. Assuming the sum of the vector sizes is even. 
  40.  
  41.                                                 -- Jan Brittenson 
  42.                                                    bson@ai.mit.edu 
  43.  
  44.                                            Read my lisp: no new classes! 
  45.  
  46. ---------- 
  47.  
  48.   Resp: 3 of 3 by rouben at math13.math.umbc.edu 
  49. Author: [Rouben Rostamian] 
  50.   Date: Sat Mar 09 1991 15:12  
  51.  
  52. Here is a somewhat shorter version (53 bytes compared to 73) of the 
  53. program above: 
  54.  
  55. Checksum: #23189d 
  56. Bytes:         53 
  57.  
  58. << SWAP OBJ-> OBJ-> DROP 1 + ROLL 
  59.         OBJ-> OBJ-> DROP 2 SWAP 
  60.         2 ->LIST ->ARRY 
  61. >> 
  62.  
  63. -- 
  64. Rouben Rostamian                          Telephone: (301) 455-2458 
  65. Department of Mathematics and Statistics  e-mail: 
  66. University of Maryland Baltimore County   bitnet: rostamian@umbc.bitnet 
  67. Baltimore, MD 21228,  U.S.A.              internet: rouben@math9.math.umbc.edu 
  68.  
  69. ---------- 
  70.  
  71. Item: 2370 by sburke at jarthur.Claremont.EDU 
  72. Author: [Scott Burke] 
  73.   Subj: 2 Vectors -> Array 
  74.   Date: Sat Mar 09 1991 
  75.  
  76.  
  77. Hey, while we're at it, here's an even _shorter_ version, which saves 10 more 
  78. bytes: 
  79.  
  80. << 
  81.   SWAP OBJ-> EVAL     @ EVAL replaces OBJ-> DROP 
  82.   1 + ROLL OBJ-> 
  83.   2 SWAP + ->ARRY     @ why blow up the list if you're going to re-make it? 
  84. >> 
  85.  
  86. Checksum # 52064d; 37.5 bytes for the program object 
  87.  
  88.  
  89. Scott. 
  90. sburke@jarthur.claremont.edu 
  91.